<?php namespace Phpcmf\Model\Fstatus;

// 权限验证
use Monolog\Handler\IFTTTHandler;

class Auth extends \Phpcmf\Model
{

    // 判断链接的显示权限
    public function is_auth($c, $m) {
        if (APP_DIR.'-'.\Phpcmf\Service::L('Router')->method.'-'.\Phpcmf\Service::L('Router')->method == '-home-index') {
            return 0;
        }
        return 1;
    }

    public function is_bottom_auth($mid) {

        $field = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $mid, 'field', 'fstatus');
        if ($field) {
            if ($field['setting']['show_admin']) {
                if (dr_in_array(1, $this->admin['roleid'])) {
                    return 1;
                } elseif (dr_array_intersect($this->admin['roleid'], $field['setting']['show_admin'])) {
                    return 1;
                }
                return 0;
            }
            return 1;
        }

        return 0;
    }

    public function is_link_auth($mid) {

        $field = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $mid, 'field', 'fstatus');
        if ($field) {
            if ($field['setting']['show_admin']) {
                if (dr_in_array(1, $this->admin['roleid'])) {
                    return 1;
                } elseif (dr_array_intersect($this->admin['roleid'], $field['setting']['show_admin'])) {
                    return 1;
                }
                return 0;
            }
            return 1;
        }

        return 0;
    }

}